<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="/tags/simple" prefix="s" %>
<!DOCTYPE html>
<html style="width:100%;height:100%;overflow:hidden">
<head>
<title>用户管理-五常优质水稻溯源监管平台</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/style/index.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/themes/icon.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/themes/color.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/common.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/form2js.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/json2.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
</head>
<body class="easyui-layout">
	<div region="center" border="false" style="padding: 5px;">
		<fieldset id="queryBlock" class="fieldset_common_style">
			<form id="inputForm" name="inputForm" method="get"
				action="${pageContext.request.contextPath}/airMoni/list">
				<input type='hidden' id="pageTotal" name="pageTotal"
					value="${pageModel.totalCount }" /> <input type="hidden" id="page"
					name="page" value="${pageModel.page }"> <input type="hidden"
					id="pageSize" name="pageSize" value="${pageModel.pageSize }">
				<table class="table_common_style">
					<tr>
						<td class="table_common_td_label_query_style">监测日期：</td>
						<td class="table_common_td_txt_query_style"><input class="easyui-datebox" id="beginDate" name="beginDate"
							value="${beginDate }"
							data-options="required:false,showSeconds:false"
							style="width: 150px" editable="false" /> ~ <input
							class="easyui-datebox" id="endDate" name="endDate" value="${endDate }"
							data-options="required:false,showSeconds:false"
							style="width: 150px" editable="false" /></td>
						<td align="right" valign="bottom"><a href="#"
							class="easyui-linkbutton" onclick="return form_check();"> <span
								class="l-btn-left"><span
									class="l-btn-text icon-search l-btn-icon-left">查询</span></span></a></td>
					</tr>
				</table>
			</form>
		</fieldset>
		<fieldset id="toolBlock" class="fieldset_common_style">
			<table>
				<tr>
					<td><a href="#" class="easyui-linkbutton" onclick="view();">
							<span class="l-btn-left"> <span
								class="l-btn-text icon-view l-btn-icon-left">查看</span>
						</span>
					</a> <a href="#" class="easyui-linkbutton" onclick="add();"> <span
							class="l-btn-left"> <span
								class="l-btn-text icon-add l-btn-icon-left">添加</span>
						</span>
					</a> <a href="#" class="easyui-linkbutton" onclick="edit();"> <span
							class="l-btn-left"> <span
								class="l-btn-text icon-edit l-btn-icon-left">修改</span>
						</span>
					</a> <a href="#" class="easyui-linkbutton"
						onclick="return deleteRecord();"> <span class="l-btn-left">
								<span class="l-btn-text icon-remove l-btn-icon-left">删除</span>
						</span>
					</a></td>
				</tr>
			</table>
		</fieldset>
		<table id="data" class="easyui-datagrid" striped="true" url="${pageContext.request.contextPath }/airMoni/list"
			singleSelect="true" pageSize="${pageModel.pageSize }"
			pageNumber="${pageModel.page }" >
			<thead>
				<tr>
					<th field="id" width="140" align="center" checkbox="true"></th>
					<th field="monitorDate" width="120" align="center">监测日期</th>
					<th field="monitorPoint" width="120" align="center">监测点位</th>
					<th field="tsp" width="120" align="center">TSP(mg/m³)</th>
					<th field="so2" width="120" align="center">SO2(mg/m³)</th>
					<th field="no2" width="120" align="center">NO2(mg/m³)</th>
					<th field="createDate" width="120" align="center">创建人</th>
					<th field="createUserId" width="120" align="center">创建日期</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${pageModel.result }" var="air">
					<tr>
						<td>${air.id }</td>
						<td><fmt:formatDate value="${air.monitordate }" type="both"/> </td>
						
						<td>${air.monitorpointcode }</td>
						<td>${air.tsp }</td>
						<td>${air.so2 }</td>
						<td>${air.no2 }</td>
						<td><s:showName value="${air.createuserid }" entityName="usercode"></s:showName> </td>
						<td><fmt:formatDate value="${air.createdate }" pattern="yyyy-MM-dd"/></td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</div>
	<div id="addDialog" style="overflow: hidden"></div>

	<script type="text/javascript">
		$(document).ready(function() {
			 var winHeight = $(window).height();
		     var queryBlockHeight = $("#queryBlock").height();
		     var toolBlock = $("#toolBlock").height();
		     height:winHeight -queryBlockHeight -toolBlock-28,
			$("#data").datagrid({
				height:winHeight -queryBlockHeight -toolBlock-46,
				pagination : true,
				rownumbers : true,
				fitColumns : false,
				//fit : true,
				pageList : [ 10, 15, 20 ],
				pagePosition : "top"
			});

			var pagger = $('#data').datagrid('getPager');
			$(pagger).pagination({
				total : $("#pageTotal").val(),
				pageNumber : parseInt($("#page").val()),
				showPageList : true,
				showRefresh  : false,
				onSelectPage : function(pageNumber, pageSize) {
					$('#page').val(pageNumber);
					$('#pageSize').val(pageSize);
					showLoading();
					$('#inputForm').submit();
				}
			});
		});

		function deleteRecord(id) {
			var rows = $('#data').datagrid('getSelections');
			var length = rows.length;
			if (length < 1) {
				$.messager.alert('警告','请至少选择一条记录。','warning');
				return false;
			}
			  $.messager.confirm("确认", "您确定要删除选中的记录吗？", function (deleteAction) {
				    if (deleteAction) {
						var ids = [];
						var rows = $('#data').datagrid('getSelections');
						var length = rows.length;
						for (var i = 0; i < rows.length; i++)
							ids.push(rows[i].id);
						Public.ajaxPost('${pageContext.request.contextPath}/airMoni/delete', 
							JSON.stringify(ids)
						, function(e) {
							if (200 == e.status) {
								form_check();
							} else{
								$.messager.alert('错误','删除失败！' + e.msg,'error');
							}
							
						});
				    }
				});



		}

		function edit(id) {
			var rows = $('#data').datagrid('getSelections');
			var length = rows.length;
			if (length == 0 ) {
				$.messager.alert('警告','必须选择一条记录。','warning');
				return false;
			}
			if (length > 1) {
				$.messager.alert('警告','只能选择一条记录。','warning');
				return false;
			}
			var id = rows[0].id;
			$('#addDialog').dialog({
				title : '编辑大气监测数据',
				width : 380,
				height : 300,
				closed : false,
				cache : false,
				href : '${pageContext.request.contextPath}/airMoni/edit?id=' + id,
				modal : true
			});
		}

		function add() {
			$('#addDialog').dialog({
				title : '添加大气监测数据',
				width : 380,
				height : 300,
				closed : false,
				cache : false,
				 href: '${pageContext.request.contextPath}/airMoni/add',
				modal : true
			});
		}

		function closeEdiDialog() {
			$('#graiEvalEditDlg').dialog('close');
		}

		function form_check() {
			var beginDate =$.trim($("#beginDate").datebox('getValue'));
			var endDate =$.trim($("#endDate").datebox('getValue'));
			if(!dateCompare(beginDate,endDate)){
				$.messager.alert('警告','监测日期开始日不能大于结束日。','warning');
				return false;
			}
			showLoading();
			$('#inputForm').submit();
		}
		
		function view() {
			var rows = $('#data').datagrid('getSelections');
			var length = rows.length;
			if (length == 0 ) {
				$.messager.alert('警告','必须选择一条记录。','warning');
				return false;
			}
			if (length > 1) {
				$.messager.alert('警告','只能选择一条记录。','warning');
				return false;
			}
			var id = rows[0].id;
			$('#addDialog').dialog({
				title : '查看大气监测数据',
				width : 380,
				height : 300,
				closed : false,
				cache : false,
				href : 'view?id=' + id,
				modal : true
			});
		}
		
	</script>
</body>
</html>